package book;

class Students {
    private int age;
    private String name;
    static String classname;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

//代码块
class store {
    //成员变量
    int one = 1;
    char two = '2';
    //静态代码块
    static int three;
    static String four;

    public store() {
        System.out.println("it's init");
    }



    //静态代码块
    static{
        three = 22;
        four = "hadage";
        System.out.println("这是第49行的静态代码");
    }

    static{
        System.out.println("这是第53行的静态代码");
    }

    //实例代码块
    {
        System.out.println("这是第54行的实例代码");
    }
    {
        System.out.println("这是第57行的实例代码");
    }
    public static void show_static() {

        System.out.printf("three = %d four = %s" +
                "", three, four);
    }
    public void show() {
        System.out.printf("one = %d two = %c", one, two);
    }
}

//执行顺序
class Order {
    int a;

    public Order(int a) {
        this.a = a;
        System.out.println("这是类的构造方法");
    }
    static{
        System.out.println("这是77行的静态方法");
    }

    {
        System.out.println("这是81行的实例代码");
    }

}
public class static_book {
    public static void main(String[] args) {
        Order h = new Order(3);
    }
    public static void hh() {
        //普通代码块
        {
            System.out.println("hh");
        }
    }

    public static void main3(String[] args) {
        //并没有创建对象
        store.show_static();
//        store h = new store();
//
//        h.show_static();
        //h.show();
//        store.show_static();
    }

    public static void main1(String[] args) {
        Students.classname = "hadage";
        System.out.println(Students.classname);
        Students hh = new Students();
        hh.classname = "haah";
        System.out.println(Students.classname);

    }
}
